﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Models.User.PlayTypeOptionModel>" %>

<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    返点设置
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
    <style type="text/css">
        .table td { padding:3px 0px}
        input[type='checkbox']{ margin:1px;}
        .validation_summary_div ul{ float:left; overflow:hidden; height:auto;}
        .validation_summary_div li{ float:left; overflow:hidden; height:auto; width:235px; line-height:21px;  text-align:left;
        list-style-type:decimal; list-style-position:inside; font-weight:normal; font-family:Arial; font-size:12px;}
    </style>
    <script src='<%=Url.Content("~/Scripts/jquery.metadata.js") %>' type="text/javascript"></script>
    <script type="text/javascript">
        var url = '<%=Url.Action("PlayTypeOption", new { id="",act=Request["act"],cont=Request["cont"],returnurl=Request["returnurl"],Model.Uid})%>';
        function ddlChage(o) {
            document.location.href = url + '&id=' + o.value;
        }
        $(document).ready(function () {

            var str = null;
            $("#optionform").validate();
            $("#optionform .table input[validate]").each(function () {
                $(this).parent().css("text-align", "left");
            });
            $("input[modelid]").change(function () {
                var item = $(this);
                var modelid = item.attr("modelid");
                str = item.attr("cktype");
                var cktype = null;
                if (str != undefined) {
                    cktype = eval("(" + str + ")");
                }
                var num = _ParseDouble(this.value);
                if (num == null || num < 0)
                    return;
                else {
                    $("." + modelid + " :text").each(function () {
                        if (cktype != null) {
                            str = $(this).attr("playtype");
                            var flag = false;
                            for (var i in cktype.play) {
                                var item = cktype.play[i];
                                if (item == str) {
                                    flag = true;
                                    break;

                                }
                            }

                            if ((flag == true && cktype.contain == true) || (cktype.contain == false && flag == false)) {
                                this.value = num;
                            }
                        } else {
                            var tp = _ParseDouble($(this).attr("oldvalue"));
                            str = num.div(100).mul(tp);
                            this.value = str;
                        }
                        $(this).valid();
                    });
                }
            }).keypress(function (e) {
                if (e.keyCode == 13) {
                    e.keyCode = 9;
                    this.blur();
                    return false;
                }
            });
        });
    

        
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <% Html.DisableClientValidation(); %>
        <% Html.BeginForm(new { id = "optionform" }, new {lottery=Model.LotteryID }); %>
        <fieldset>
            <legend>[<%=Model.UserName %>]奖金设置</legend>
            <% if (Request["returnUrl"] != null) %>
            <% { %>
            <a href='<%=Request["returnUrl"] %>' class="a_blue">&gt;&gt;返回</a> |
            <% } %>
            <%=Html.ActionLink("奖金/返点差调整", "SubWinMoneyMargin", new { ID = Model.Uid ,act="PlayTypeOption",ReturnUrl=Request["ReturnUrl"] }, new { @class = "a_blue" })%>
            <br />
            <br />
          我的返点详情：
            <table class="table" width="100%">
                <%
                var groupwin = Model.Options.GroupBy(p => new { Name=p.WinMoneyName ,ID=p.Option.WinMoneyModelID});
                var wins = groupwin.Select(p => p.Key).OrderBy(p=>p.ID).ToArray();
              %>
                <tr>
                    <th rowspan="2">
                     类型\ 
                    </th>
                    <% foreach (var item in wins) %>
                    <% { %>
                    <th colspan='2'>
                      
                        <%=item.Name %>
                       
                    </th>
                    <% } %>
                </tr>
                <tr>
                   
                </tr>
                <% var single = groupwin.First().OrderBy(p => p.Option.BackMoneyTypeID).Select(p => new { p.PlayNames, p.Option.BackMoneyTypeID, p.Option.WinMoneyModelID }); %>
                <% foreach (var pl in single)%>
                <% { %>
                <tr>
                    <td>
                        <%=pl.PlayNames%>
                    </td>
                
                    <% foreach (var win in wins)%>
                    <% { %>
                    <% var i = Array.FindIndex(Model.Options, p => p.Option.BackMoneyTypeID == pl.BackMoneyTypeID && p.Option.WinMoneyModelID == win.ID ); %>

                    
                    <% var item = Model.Options[i]; %>
                   
                    <td class='<%=win.ID + "BackMoney"%>' colspan="2">
                        <%if (Model.UseSiteBackMoneyRatio) %>
                        <% { %>
                        <%=item.CurrentBackMoneyRatio%>
                        <% } %>
                        <% else %>
                        <% { %>
                        <%=Html.Encode(item.CurrentBackMoneyRatio)%>
                        
                        <% } %>
                    </td>
                    <% } %>
                </tr>

              <%} %>
            </table>
            <br />
          会员返点设置：
            <br />
             <table class="table" width="100%">
             
                <tr>
                    <th rowspan="2">
                     类型\ 模式
                    </th>
                    <% foreach (var item in wins) %>
                    <% { %>
                    <th colspan='2'>
                    <% var result = Array.FindIndex(Model.Options, p => p.Option.WinMoneyModelID == item.ID); %>
                        <%=item.Name %>
                       <%
                           if (Model.Options[result].MyState && Model.WinMoneyState)
                              %>
                       <%{ %>
                            &nbsp;&nbsp;
                        <%= Html.CheckBoxFor(p => p.Options[result].States, "State")%>
                       <%} %>
                    </th>
                    <% } %>
                </tr>
                <tr>
                
                </tr>
                <% foreach (var pl in single)%>
                <% { %>
                <tr>
                    <td>
                        <%=pl.PlayNames%>
                    </td>
                
                    <% foreach (var win in wins)%>
                    <% { %>
                    <% var num = Array.FindIndex(Model.Options, p => p.Option.BackMoneyTypeID == pl.BackMoneyTypeID && p.Option.WinMoneyModelID == win.ID ); %>
                      
                    <% var item = Model.Options[num]; %>
                    
                    <td class='<%=win.ID + "BackMoney"%>' colspan="2">
                     <%=Html.HiddenFor(p => p.Options[num].Option.WinMoneyModelID)%>
                      <%=Html.HiddenFor(p => p.Options[num].Option.BackMoneyTypeID)%>
                        <%if (Model.UseSiteBackMoneyRatio) %>
                        <% { %>
                        <%=item.Option.BackMoneyRatio%>
                        <% } %>
                        <% else %>
                        <% { %>
                     <%=Html.TextBoxFor(p => p.Options[num].Option.BackMoneyRatio, new { @class = "text50", playtype = item.Option.BackMoneyTypeID, oldvalue = item.Option.BackMoneyRatio, validate = string.Format("{{required:true,number:true,min:{0},max:{1},messages:{{required:'*',number:'*',min:'>={0}',max:'<={1}'}}}}", item.Option.MinBackMoneyRatio, item.Option.MaxBackMoneyRatio) })%>
                        <%=Html.ValidationMessageFor(p => p.Options[num].Option.BackMoneyRatio)%>
                        <% } %>
                    </td>
                    <% } %>
                </tr>
              <%} %>
                <tr>
                    <td colspan="7">
                   
                       <input type="submit" <%=ViewData["btnAddDisabled"]!=null&&((bool)ViewData["btnAddDisabled"])?"disabled='disabled'":"" %> value="保存" onclick="return confirm('确定提交吗？')" />&nbsp;&nbsp;
          
                        &nbsp;&nbsp;
                        <input type="reset" value="重设" />
                    </td>
                </tr>
            </table>
        </fieldset>
        <%=Html.HiddenFor(p=>p.Uid) %>
        <%=Html.SerializableFor(p=>p.Lotterys) %>
        <%Html.EndForm(); %>
    </div>
</asp:Content>
